#!/bin/bash
echo "start receive pay ...."

dir='/cyzz/pp/api'
cd $dir

# paid
while true; do
  # 获取进程号
  pid=$(ps aux | grep auto/order-paid | grep -v grep | awk '{print $2}')
  #    pidCount=$(ps aux | grep auto/run-queue |grep -v grep |  awk '{print $2}' | wc -l )
  echo ${pid}
  # [ -z STRING ] “STRING” 的长度为零则为真。
  if [ -z "$pid" ]; then
    echo "restart..."
    nohup php ./yii auto/order-paid &
  else
    echo "running..."
  fi
  sleep 5
done
